package initialize

import (
	"fmt"
	"github.com/zeromicro/go-zero/core/logx"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

// DBConn Db数据库连接池
//var DBConn *gorm.DB

func DBinit(account, password, host, database string) *gorm.DB {
	dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", account, password, host, database)
	DBConn, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		// handle error
		logx.Error("mysql init error")
		return nil
	}
	return DBConn
}
